package cn.driver.coach.service.impl;

import cn.driver.coach.mapper.CoachMapper;
import cn.driver.coach.service.CoachService;
import cn.driver.common.pojo.Car;
import cn.driver.common.pojo.Coach;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoachServiceImpl implements CoachService {
    @Autowired
    private CoachMapper coachMapper;

    /**
     * 查询所有教练
     *
     * @return
     */
    @Override
    public List<Coach> getCoachList() {
        return coachMapper.getCoachList();
    }

    @Override
    public int addCoach(Coach coach) {
        return coachMapper.addCoach(coach);
    }

    @Override
    public int delete(int account) {
        return coachMapper.deleteCoach(account);
    }

    @Override
    public List<Coach> getList(int pageNum, int pageSize) {
        //使用分页插件,核心代码就这一行
        PageHelper.startPage(pageNum, pageSize);
        // 获取
        List<Coach> typeList = coachMapper.getCoachList();
        return typeList;
    }

    @Override
    public int update(Coach coach) {
        return coachMapper.updateCoach(coach);
    }

    @Override
    public List<Coach> mohuList(String coachName) {
        return coachMapper.mohuList(coachName);
    }
}
